import { ChangeBgmParams as Params } from '@swda/configs/params'

let SWDA_ChangeBgm = {};


// 控制切换场景时是否切换BGM


SWDA_ChangeBgm.Game_Map_Autoplay = Game_Map.prototype.autoplay;

Game_Map.prototype.autoplay = function() {
    if ($dataMap.autoplayBgm){
        if (Params.changeBgm){
            $dataMap.autoplayBgm = true;
        }else{
            $dataMap.autoplayBgm = false;
        }
    }
    SWDA_ChangeBgm.Game_Map_Autoplay.call(this);

};

//---------------------------
//          Game_Interpreter【插件指令】
//---------------------------
SWDA_ChangeBgm.PLUGIN_COMMAND = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function (command, args) {
    SWDA_ChangeBgm.PLUGIN_COMMAND.call(this, command, args);

    if (command === 'ChangeBgm') {
        var ChangeItemMsgAction = args[0];
        if (ChangeItemMsgAction.toUpperCase() === "ON")
            Params.changeBgm = true;
        if (ChangeItemMsgAction.toUpperCase() === "OFF")
            Params.changeBgm = false;
    }
};